package com.xpgk.mvc.statistic.monthShopManagerAndEmployeeKeyIndex;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.bouncycastle.crypto.tls.MACAlgorithm;

import com.jfinal.aop.Before;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.xpgk.annotation.Service;
import com.xpgk.constant.ConstantRender;
import com.xpgk.dto.RenderBean;
import com.xpgk.mvc.base.BaseService;
import com.xpgk.mvc.bloseWeight.DelWeiTarget;
import com.xpgk.mvc.statistic.dailyNursing.DailyNursingStatisticSQL;
import com.xpgk.mvc.statistic.loseWeightList.LoseWeightListSQL;
import com.xpgk.mvc.statistic.spropagandaTraining.SpropagandaTrainingSQL;
import com.xpgk.tools.ToolDateTime;


@Service(name = MonthShopManagerAndEmployeeKeyIndexService.serviceName)
public class MonthShopManagerAndEmployeeKeyIndexService extends BaseService{

	@SuppressWarnings("unused")
	private static final Log log = Log.getLog(MonthShopManagerAndEmployeeKeyIndexService.class);
	public static final String serviceName = "monthShopManagerAndEmployeeKeyIndexService";
	
	
	
	/*
	 * util：查询机构级别
	 */
	public String level(String organizationids){
		String organizationlevel = 
				"SELECT "
				+ "syso.ids,syso.`name`,syso.`level`,syso.parentIds "
				+ "FROM "
				+ "sys_organization AS syso "
				+ "WHERE "
				+ "syso.ids='"+organizationids+"'";
		String level = Db.find(organizationlevel).get(0).get("level").toString();
		return level;
	}
	/*
	 * util:查询下一个级别的机构
	 */
	public List<Record> nextlevellist(String organizationids){
		
		String organizationlist = 
				"SELECT "
				+ "syso.ids,"
				+ "syso.`name`,"
				+ "syso.`level`,"
				+ "syso.parentIds "
				+ "FROM "
				+ "sys_organization AS syso "
				+ "WHERE "
				+ "parentIds='"+organizationids+"'";
		List<Record> nextlist = Db.find(organizationlist);
		return nextlist;
	} 
	/*
	 * 隶属查询
	 */
	
	public List<Record> query(String organIds,String organMangerIds){
		List<Record> result = new ArrayList<Record>();
		String times;
		if(this.level(organIds).equals("4")){
			
		}else{
			List<Record> find1 = this.nextlevellist(organIds);
			if(find1.get(0).get("level").toString().equals("4")){
				
			}else{
				
			}
		}
		
		
		
		//判断机构等级
		
		
		
//		String organizationlevel = "SELECT syso.ids,syso.`name`,syso.`level`,syso.parentIds FROM sys_organization AS syso WHERE ids=?";
//		List<Record> organizationlevellist = Db.find(organizationlevel,organIds);
//		if(organizationlevellist.size()>0){
//			for(Record organ : organizationlevellist){
//				System.out.println(organ.get("level"));
//			}
//		}
		
		
		
		
		
		
		
//		Map<String,Object> param = new HashMap<String,Object>();
//		List<Record> result = find(MonthShopManagerAndEmployeeKeyIndexSQL.monthShopmanagerandemployeekeyindex_querysubjection,param);
		return null;
	}
}
